# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-
# from robyn.robyn import Request, Identity
# from sqlalchemy.ext.asyncio import AsyncSession
# from typing import Optional, List, Callable, Any, Coroutine
# from contextvars import ContextVar

# from database.db import SessionLocal
# from common.exception.errors import CustomException
# from common.response.response_code import StandardResponseCode

# _session_var: ContextVar[Optional[AsyncSession]] = ContextVar("_session", default=None)

# async def get_db() -> AsyncSession:
#     session = _session_var.get()
#     if session is None:
#         raise CustomException(
#             code=StandardResponseCode.HTTP_500,
#             msg="Data session not initialized"
#         )
#     return session

# async def get_db_before_request(request: Request):
#     async with SessionLocal() as session:
#         _session_var.set(session)
#         return request